<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;

class order_expire extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'songshu:order_expire';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '设置过期订单失效';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        $ago = date("Y-m-d H:i:s",strtotime("-3 minute"));
        $affect = DB::table('order')->where('pay_status',0)->where('time_expire','<',$ago)->update(['status'=>0]);
        echo $affect."\n";
    }
}